package com.lianbang.pharmacy.module.user

import android.os.Bundle
import android.view.View
import cn.ubest.mvvmcore.base.BaseListFragment
import cn.ubest.mvvmcore.interfaces.IEmptyView
import cn.ubest.mvvmcore.utils.DoubleClickHelper
import com.chad.library.adapter.base.BaseQuickAdapter
import com.lianbang.pharmacy.R
import com.lianbang.pharmacy.adapter.OrderListAdapter
import com.lianbang.pharmacy.databinding.FragmentSearchHistoryBinding
import com.lianbang.pharmacy.module.main.MainActivity
import com.lianbang.pharmacy.vm.MainVM

/**
 * Created by maoqi on 2020/11/23.
 */
class OrderListFragment : BaseListFragment<MainVM, FragmentSearchHistoryBinding, String>(),
    IEmptyView {

    companion object {
        fun newInstance(): OrderListFragment {
            return OrderListFragment()
        }
    }

    override fun initLayout(): Int {
        return R.layout.include_list_with_refresh
    }

    override fun initData(arguments: Bundle?) {
        super.initData(arguments)
    }

    override fun initView(view: View) {
        super.initView(view)
    }

    override fun loadData() {
        mViewModel.setData(mutableListOf())
    }

    override fun initAdapter(): BaseQuickAdapter<String, *> {
        return OrderListAdapter()
    }

    override fun getEmptyView(): View {
        val v = layoutInflater.inflate(R.layout.empty_order_list, null)
        v.findViewById<View>(R.id.btn_submit)
            .setOnClickListener(object : DoubleClickHelper.OnClickListener() {
                override fun onClicked(view: View?) {
                    MainActivity.start(activity, MainActivity.TAB_HOME)
                    activity?.finish()
                }
            })
        return v
    }

}